package JUC.wn_syn_vlo;

import java.util.concurrent.atomic.AtomicInteger;

public class 原子类_atomic_替掉_syn {

    // static int i  = 0;
    static AtomicInteger atomicInteger = new AtomicInteger();

    public static void main(String[] args) throws Exception {
        Thread t1 = new Thread(() -> {
            for (int j = 0; j < 3000000; j++) {
                atomicInteger.incrementAndGet();
            }
        });
        t1.start();
        Thread t2 = new Thread(() -> {
            for (int j = 0; j < 3000000; j++) {
                atomicInteger.incrementAndGet();
            }
        });
        t2.start();
        t1.join();t2.join();
        System.out.println(atomicInteger);
    }
}
